<template>
	<view class="content-header-f">
		<view class="top40"></view>
		<view class="banner">
			<view class="banner-top flex-row flex-content-between">
				<view class="flex-column banner-txt" v-if="userInfo!=null">
					<view>我的积分</view>
					<view>{{userInfo.score}}</view>
				</view>
				
			</view>
		</view>
		<view class="top60"></view>
		<view class="log">
			<view class="log-header flex-row flex-content-between">
				<view>积分明细</view>
				<view>
					<picker mode="date" fields="month" @change="bindPickerChange">
											<view class="uni-input">{{seachTxt}}</view>
										</picker>
				</view>
			</view>
			<view v-if="logList.length==0">
				<view class="flex-column">
					<image class="not-img" src="../../static/bank/notlist.png" mode="scaleToFill"></image>
					<view class="not-txt">暂无数据</view>
				</view>
			</view>
			<view v-if="logList.length>0">
				<view class="taile">
					<scroll-view :scroll-y="true" class="detal-scroll" @scrolltolower="getScore">
						<view class="one" v-for="order in logList">
							<view class="flex-row flex-content-between one-top flex-item-center">
								<view class="flex-column one-txt">
									<view>{{order.memo}}</view>
									<view>{{order.createtime}}</view>
								</view>
								<view :class="order.change_type==1?`one-price`:`one-prices`">{{order.change_type==1?`+`:`-`}}{{order.money}}</view>
							</view>
						
						</view>
					</scroll-view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				seachTxt: "日期选择",
				page:1,
				date:"",
				logList: [
				], //记录的数据
			}
		},
		onLoad() {
			this.getScore();
			this.$store.dispatch("getUserInfo");
		},
		computed:{
			userInfo(){
				return this.$store.state.user.userInfo
			}
		},
		onPullDownRefresh() {
			this.page = 1;
			this.logList = [];
			this.date = '';
			this.getScore(()=>{
				uni.stopPullDownRefresh();
			});
			
		},
		methods: {
			//获取积分列表
			getScore(callback){
				let data = {
					page:this.page,
					type:'score',
					date:this.date
				}
				if(!data.page){
					return
				}
				let that = this;
				this.$api.getBalanceLog(data).then(res=>{
					console.log(res);
					if(res.data.length>0){
						that.logList.push(...res.data);
						that.page++;
					}else{
						that.page = 0;
					}
				}).finally((e)=>{
					if((typeof callback)=="function"){
						callback()
					}
				})
			},
			//选择日期
			bindPickerChange(e){
				// console.log(e);
				var value = e.detail.value;
				this.seachTxt = value;
				this.date = value;
				this.page = 1;
				this.logList = [];
				this.getScore();
				
			}
		}
	}
</script>

<style lang="scss">
	.uni-input{
		width: 157rpx;
		height: 56rpx;
		background: #F3F5F5;
		border-radius: 26rpx 26rpx 26rpx 26rpx;
		opacity: 1;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		text-align: center;
		line-height: 56rpx;
	}
	.one-top{
		padding-top: 15rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}
	.one-price{
		font-size: 30rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #00aa00;
	}
	.one-prices{
		font-size: 30rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #ff0000;
	}
	.one-txt{
		>view:nth-child(1){
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		>view:nth-child(2){
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			margin-top: 16rpx;
		}
	}
	.one{
		width: 690rpx;
		height: 129rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 1rpx rgba(0,0,0,0.05);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		margin-bottom: 34rpx;
		// margin-top: 30rpx;
		// margin-left: 30rpx;
		// margin-right: 30rpx;
	}
	/* #ifdef H5 */
	.detal-scroll{
		width: 690rpx;
		height: calc(100vh - 510rpx);
		// background-color: #ff5500;
	}
	/* #endif */
	
	/* #ifdef APP-PLUS */
	.detal-scroll{
		width: 690rpx;
		height: calc(100vh - 410rpx);
		// background-color: #ff5500;
	}
	/* #endif */
/* #ifdef MP */
	.detal-scroll{
		width: 690rpx;
		height: calc(100vh - 410rpx);
		// background-color: #ff5500;
	}
	/* #endif */
	.taile {
		// margin-left: 30rpx;
		margin-right: 30rpx;
		padding-top: 34rpx;
	}

	.not-txt {
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		text-align: center;
		margin-top: 30rpx;
	}

	.not-img {
		width: 288rpx;
		height: 241rpx;
		margin-top: 126rpx;
		margin-left: 201rpx;
	}

	.log-header {
		>view:nth-child(1) {
			font-size: 34rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		>view:nth-child(2) {
			width: 157rpx;
			height: 56rpx;
			background: #F3F5F5;
			border-radius: 26rpx 26rpx 26rpx 26rpx;
			opacity: 1;
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			text-align: center;
			line-height: 56rpx;
		}
	}

	.log {
		width: 690rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}

	.banner-img {
		width: 13rpx;
		height: 21rpx;
		margin-left: 12rpx;
	}

	.banner-tx {
		width: 169rpx;
		height: 60rpx;
		background: #EFB225;
		border-radius: 33rpx 0px 0px 33rpx;
		opacity: 0.7;
		text-align: center;
		margin-top: 20rpx;

		>view:nth-child(1) {
			font-size: 26rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			margin-left: 26rpx;
		}
	}

	.banner-txt {
		>view:nth-child(1) {
			font-size: 28rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
		}

		>view:nth-child(2) {
			font-size: 66rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
	}

	.banner-top {
		padding-top: 54rpx;
		margin-left: 30rpx;
		padding-bottom: 20rpx;
	}

	.banner {
		width: 690rpx;
		// height: 196rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
		/* #ifdef MP */
		background-image: url('http://ws.facai.maowenke.cn/img/bj.png');
		/* #endif */
		/* #ifndef MP */
		background-image: url('../../static/bank/bj.png');
		/* #endif */
		background-size: 100%;
	}
</style>